import crypto from 'crypto'

export type CryptoAlgorithm = 'sha256' | 'sha1' | 'md5'

export function cryptoString (str: string, algorithm: CryptoAlgorithm = 'sha256'): string {
  const hash = crypto.createHash(algorithm)
  hash.update(str)
  return hash.digest('hex')
}
